package org.bit.lesson08;

public class Demo_802 {
    public static void main(String[] args) throws InterruptedException {
        
        // 创建定时器对象
        MyTimer timer = new MyTimer();
        // 向定时器中添加任务
        timer.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("马上执行任务1");
            }
        }, 0);
        // 向定时器中添加任务
        timer.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("马上执行任务2");
            }
        }, 0);
        // 向定时器中添加任务
        timer.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("马上执行任务3");
            }
        }, 0);

        // 向定时器中添加任务
        timer.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("任务1");
            }
        }, 1000);
        timer.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("任务2");
            }
        }, 2000);
        timer.schedule(new Runnable() {
            @Override
            public void run() {
                System.out.println("任务3");
            }
        }, 3000);
    }
}
